using CampusModel.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CampusModel.Configuration;

public class AttendanceRecordConfiguration: IEntityTypeConfiguration<AttendanceRecord>
{

    public void Configure(EntityTypeBuilder<AttendanceRecord> builder)
    {
        builder.HasKey(ar => ar.AttendanceID);
        builder.HasOne(ar => ar.Course).WithMany(c => c.AttendanceRecords).HasForeignKey(ar => ar.CourseID);
        builder.HasMany(ar => ar.Students).WithMany(s => s.AttendanceRecords).UsingEntity("AttendanceRecordStudent"); 
    }
}